//package com.qiang.service.impl;
//
//import com.gofun.car.interfaces.ParkingRMI;
//import com.gofun.car.vo.parking.ParkingSimpleVo;
//import com.gofun.ms.common.util.CollectionUtils;
//import com.gofun.station.enums.DictionaryConfigEnum;
//import com.gofun.station.enums.RecommendEnums;
//import com.gofun.station.enums.StationExceptionCode;
//import com.gofun.station.enums.StationRecomParkingOpenStatusEnums;
//import com.gofun.station.exception.ResultException;
//import com.gofun.station.mapper.*;
//import com.gofun.station.model.*;
//import com.gofun.station.po.*;
//import com.gofun.station.service.*;
//import com.gofun.station.util.DistributedLock;
//import com.gofun.station.util.RMICheckUtil;
//import com.gofun.station.util.RMICheckUtils;
//import com.gofun.station.util.TaskPoolExecutor;
//import com.gofun.station.vo.*;
//import com.google.common.collect.Lists;
//import com.google.common.collect.Maps;
//import com.netflix.discovery.converters.Auto;
//import org.apache.commons.lang3.StringUtils;
//import org.apache.ibatis.jdbc.Null;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.BeanUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.expression.Operation;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.util.*;
//import java.util.concurrent.*;
//import java.util.stream.Collectors;
//
///**
// * @Auther: chenguang
// * @Date: 2019/5/31 16:43
// * @Description:推荐建点相关service
// */
//@Service
//public class RecommendServiceImpl implements RecommendService {
//
//
//    private static Logger logger = LoggerFactory.getLogger(RecommendServiceImpl.class);
//
//    @Autowired
//    private StationRecomUserMapper stationRecomUserMapper;
//
//    @Autowired
//    private StationRecomUserParkingMapper stationRecomUserParkingMapper;
//
//    @Autowired
//    private StationRecomParkingMapper stationRecomParkingMapper;
//
//    @Autowired
//    private StationCarDictionaryConfigService stationCarDictionaryConfigService;
//
//    @Autowired
//    private StationRecomShareMapper stationRecomShareMapper;
//
//    @Autowired
//    private TaskPoolExecutor taskPoolExecutor;
//
//    @Autowired
//    private static final Integer FIREND_LIST_MAX_SIZE = 20;
//
//    @Autowired
//    private StationInfoService stationInfoService;
//
//    @Autowired
//    private StationParkingContractMapper stationParkingContractMapper;
//
//    @Autowired
//    private StationRecomUserService stationRecomUserService;
//
//    @Autowired
//    private ParkingRMI parkingRMI;
//
//    private Object lock = new Object();
//
//    @Autowired
//    private DistributedLock distributedLock;
//
//    @Autowired
//    private CacheService cacheService;
//
//    @Override
//    public IfAllowRecommendVo checkIfAllowRecommend(IfAllowRecommendPo ifAllowRecommendPo) {
//        Integer count = stationRecomUserParkingMapper.findByUserIdAndPoisIds(ifAllowRecommendPo);
//        // 存在重复推荐的站点，不允许在推荐
//        IfAllowRecommendVo ifAllowRecommendVo = new IfAllowRecommendVo();
//        ifAllowRecommendVo.setAllowRecommendFlag(count > 0 ? false : true);
//        return ifAllowRecommendVo;
//    }
//
//    @Override
//    @Transactional
//    public RecommendBuildParkingVo recommendBuildParking(RecommendBuildParkingPo recommendBuildParkingPo) {
//        RecommendBuildParkingVo recommendBuildParkingVo = new RecommendBuildParkingVo();
//
//        // 保存申请范围信息（station_recom_user表）
//        int result = this.saveCircleInfo(recommendBuildParkingPo);
//        logger.info("userId={},,rangeId={} save station_recom_user result {}", recommendBuildParkingPo.getUserId(), recommendBuildParkingPo.getRangeId(), result);
//        if (result <= 0) {
//            logger.error("userId={},,rangeId={} save station_recom_user fail", recommendBuildParkingPo.getUserId(), recommendBuildParkingPo.getRangeId());
//            recommendBuildParkingVo.setRecommendResult(false);
//            return recommendBuildParkingVo;
//        }
//
//        // 保存圈内站点信息,没有该站点新建，有站点更新
//        List<RecommendParking> list = recommendBuildParkingPo.getParkingList();
//        if (CollectionUtils.isNotEmpty(list)) {
//            for (RecommendParking param : list) {
//                // 保存圈内站点信息（station_recom_user_parking）
//                int result1 = this.savePoisInfo(param, recommendBuildParkingPo);
//                logger.info("userId={},,rangeId={},,poiId={} save station_recom_user_parking result {}", recommendBuildParkingPo.getUserId(), recommendBuildParkingPo.getRangeId(),param.getPoiId(), result1);
//                if (result1 <= 0) {
//                    logger.error("userId={},,rangeId={},,poiId={} save station_recom_user_parking fail", recommendBuildParkingPo.getUserId(), recommendBuildParkingPo.getRangeId(),param.getPoiId());
//                    recommendBuildParkingVo.setRecommendResult(false);
//                    return recommendBuildParkingVo;
//                }
//
//                String prefix = "RECOMMEND_SAVE_POI_";
//                String key = param.getPoiId();
//                try {
//                    // 对同一个POI进行操作时，获取到锁才能查询，获取锁失败一直等待。最大超时时间5S
//                    while (!distributedLock.tryLock(prefix, key, 5000L)) {
//                    }
//
//                    // 查询该站点是否已经存在
//                    StationRecomParkingCriteria stationRecomParkingCriteria = new StationRecomParkingCriteria();
//                    StationRecomParkingCriteria.Criteria criteria = stationRecomParkingCriteria.createCriteria();
//                    criteria.andPoisIdEqualTo(param.getPoiId());
//                    StationRecomParking stationRecomParking = stationRecomParkingMapper.getByExample(stationRecomParkingCriteria);
//                    if (stationRecomParking != null) {
//                        // 更新站点申请人数+1
//                        StationRecomParking stationRecomParking1 = new StationRecomParking();
//                        stationRecomParking1.setId(stationRecomParking.getId());
//                        stationRecomParking1.setApplications(stationRecomParking.getApplications() + 1);
//                        int result2 = stationRecomParkingMapper.updateByPrimaryKeySelective(stationRecomParking1);
//                        logger.info("userId={},,rangeId={},,poiId={} update station_recom_parking result {}", recommendBuildParkingPo.getUserId(), recommendBuildParkingPo.getRangeId(),param.getPoiId(), result2);
//                        if (result2 <= 0) {
//                            logger.error("userId={},,rangeId={},,poiId={} update station_recom_parking fail", recommendBuildParkingPo.getUserId(), recommendBuildParkingPo.getRangeId(),param.getPoiId());
//                            recommendBuildParkingVo.setRecommendResult(false);
//                            return recommendBuildParkingVo;
//                        }
//                    }else {
//                        // 保存场站
//                        StationRecomParking stationRecomParking1 = new StationRecomParking();
//                        BeanUtils.copyProperties(param, stationRecomParking1);
//                        stationRecomParking1.setPoisId(param.getPoiId());
//                        stationRecomParking1.setPoisName(param.getPoiName());
//                        stationRecomParking1.setCreateTime(new Date());
//                        stationRecomParking1.setUpdateTime(new Date());
//                        stationRecomParking1.setOpenStatus(StationRecomParkingOpenStatusEnums.RECOMMENDED.getCode());
//                        stationRecomParking1.setApplications(1);
//                        int result2 = stationRecomParkingMapper.insertSelective(stationRecomParking1);
//                        logger.info("userId={},,rangeId={},,poiId={} save station_recom_parking result {}", recommendBuildParkingPo.getUserId(), recommendBuildParkingPo.getRangeId(),param.getPoiId(), result2);
//                        if (result2 <= 0) {
//                            logger.error("userId={},,rangeId={},,poiId={} save station_recom_parking fail", recommendBuildParkingPo.getUserId(), recommendBuildParkingPo.getRangeId(),param.getPoiId());
//                            recommendBuildParkingVo.setRecommendResult(false);
//                            return recommendBuildParkingVo;
//                        }
//                    }
//                }finally {
//                    distributedLock.releaseLock(prefix, key);
//                }
//            }
//        }
//        // 清除缓存
//        cacheService.clearCache("REDIS_KEY_STATION_RECOMMEND_LIST#" + recommendBuildParkingPo.getUserId());
//        recommendBuildParkingVo.setRecommendResult(true);
//        return recommendBuildParkingVo;
//    }
//
//    @Override
//    public List<RecommendDetailVo> recommendList(String userId) throws InterruptedException, ExecutionException, TimeoutException {
//        Long startTime = System.currentTimeMillis();
//        StationRecomUserCriteria stationRecomUserCriteria = new StationRecomUserCriteria();
//        StationRecomUserCriteria.Criteria criteria = stationRecomUserCriteria.createCriteria();
//        criteria.andUserIdEqualTo(userId);
//        List<StationRecomUser> list = stationRecomUserMapper.selectByExample(stationRecomUserCriteria);
//        List<RecommendDetailVo> result = Lists.newArrayList();
//        if (CollectionUtils.isNotEmpty(list)) {
//            // 所有详情全部获取完才返回
//            CountDownLatch countDownLatch = new CountDownLatch(list.size());
//            for (StationRecomUser stationRecomUser : list) {
//                List<RecommendDetailVo> finalResult = result;
//                taskPoolExecutor.threadPoolTaskExecutorForAPI().execute(() -> {
//                    try {
//                        // 根据rangeId获取详情信息
//                        RecommendDetailVo recommendDetailVo = this.recommendDetail(stationRecomUser.getRangeId());
//                        finalResult.add(recommendDetailVo);
//                    }finally {
//                        countDownLatch.countDown();
//                    }
//                });
//            }
//            try {
//                // 默认3.5s超时
//                boolean await = countDownLatch.await(2500, TimeUnit.MILLISECONDS);
//                logger.info("await={}",await);
//            } catch (InterruptedException e) {
//                logger.error(String.format("userId=%s get recommendList error", userId), e);
//                Thread.currentThread().interrupt();
//                throw new ResultException(StationExceptionCode.CALL_TIMEOUT);
//            }
//            // 根据申请时间倒序排序
//            result = result.stream().sorted(Comparator.comparing(RecommendDetailVo::getApplyTime).reversed()).collect(Collectors.toList());
//            Long entTime = System.currentTimeMillis();
//            logger.info("recommendList userId={},,startTime={},,entTime={},,useTime={}", userId, startTime, entTime,  entTime - startTime);
//        }
//        return result;
//    }
//
//    @Override
//    public RecommendDetailVo recommendDetail(String rangeId) {
//        long start = System.currentTimeMillis();
//        RecommendDetailVo recommendDetailVo = new RecommendDetailVo();
//
//        // 从字典表获取最大热力值
//        StationCarDictionaryConfig stationCarDictionaryConfig1 = stationCarDictionaryConfigService.getStationCarDictionaryConfigById(DictionaryConfigEnum.id_twenty.getCode());
//        // 默认值300
//        String maxHotValue = null!=stationCarDictionaryConfig1 && StringUtils.isNotBlank(stationCarDictionaryConfig1.getConfigValue())?stationCarDictionaryConfig1.getConfigValue():"300";
//
//        // 查中心点信息
//        StationRecomUserCriteria stationRecomUserCriteria = new StationRecomUserCriteria();
//        StationRecomUserCriteria.Criteria criteria = stationRecomUserCriteria.createCriteria();
//        criteria.andRangeIdEqualTo(rangeId);
//        StationRecomUser stationRecomUser = stationRecomUserMapper.getByExample(stationRecomUserCriteria);
//        if (stationRecomUser != null) {
//            recommendDetailVo.setRangeId(rangeId);
//            recommendDetailVo.setCenterPointName(stationRecomUser.getRangeName());
//            recommendDetailVo.setCenterPointAddress(stationRecomUser.getRangeAddress());
//            // 申请时间近似为申请时间
//            recommendDetailVo.setApplyTime(stationRecomUser.getCreateTime());
//            int hotValue = stationRecomUser.getSumHeatValue().intValue();
//            recommendDetailVo.setHotPowerValue(hotValue);
//            recommendDetailVo.setLon(stationRecomUser.getLon());
//            recommendDetailVo.setLat(stationRecomUser.getLat());
//            // 热力值是否已满
//            recommendDetailVo.setFullFlag(hotValue >= Integer.parseInt(maxHotValue) ? true : false);
//            recommendDetailVo.setUserId(stationRecomUser.getUserId());
//            recommendDetailVo.setTag(StringUtils.isBlank(stationRecomUser.getTag()) ? "" : stationRecomUser.getTag());
//
//            // 获取好友列表
//            this.getFirendList(rangeId, recommendDetailVo);
//
//            // '0:默认1:成功'
//            boolean status = stationRecomUser.getStatus().equals(RecommendEnums.INIT.getCode()) ? false : true;
//            recommendDetailVo.setStatus(status);
//
//            // 根据状态返回不同model
//            // 每次助力热力值配置在字典表里
//            StationCarDictionaryConfig stationCarDictionaryConfig = stationCarDictionaryConfigService.getStationCarDictionaryConfigById(DictionaryConfigEnum.id_nineteen.getCode());
//            // 默认值10
//            String value = null!=stationCarDictionaryConfig && StringUtils.isNotBlank(stationCarDictionaryConfig.getConfigValue())?stationCarDictionaryConfig.getConfigValue():"10";
//            recommendDetailVo.setHotPowerValueEveryTime(Integer.parseInt(value));
//
//            this.returnModelByStatus(status, recommendDetailVo, rangeId);
//
//            // 获取cityCode
//            this.returnCityCode(recommendDetailVo, rangeId);
//        }
//
//        long end = System.currentTimeMillis();
//        logger.info("rangeId={},耗时{}毫秒",rangeId,(end-start));
//        return recommendDetailVo;
//    }
//
//    /**
//     * 获取cityCode
//     * @param recommendDetailVo
//     * @param rangeId
//     */
//    private void returnCityCode(RecommendDetailVo recommendDetailVo, String rangeId) {
//        // 获取圈的cityCode, 任意返回一个停车场的cityCode
//        String cityCode = stationRecomUserMapper.getCityCode(rangeId);
//        recommendDetailVo.setCityCode(cityCode);
//    }
//
//    @Override
//    public CheckIfAllowHelpVo checkIfAllowHelp(CheckIfAllowHelpPo checkIfAllowHelpPo) {
//        CheckIfAllowHelpVo checkIfAllowHelpVo = new CheckIfAllowHelpVo();
//
//        StationRecomShareCriteria stationRecomShareCriteria = new StationRecomShareCriteria();
//        StationRecomShareCriteria.Criteria criteria = stationRecomShareCriteria.createCriteria();
//        criteria.andRangeIdEqualTo(checkIfAllowHelpPo.getRangeId());
//        criteria.andOpenIdEqualTo(checkIfAllowHelpPo.getOpenId());
//        StationRecomShare stationRecomShare = stationRecomShareMapper.getByExample(stationRecomShareCriteria);
//        // 好友没推荐过该圈则允许推荐
//        checkIfAllowHelpVo.setAllowHelpFlag(stationRecomShare == null ? true : false);
//        return checkIfAllowHelpVo;
//    }
//
//    @Override
//    @Transactional
//    public HelpVo help(HelpPo helpPo, List<StationRecomUserParking> list, int helpHotValue, int maxHotValue, int applyHotValue) {
//        HelpVo helpVo = new HelpVo();
//
//        // 如果热力值已经300，不允许再次助力
//        synchronized (lock) {
//            // 串行查询
//            StationRecomUser stationRecomUser = stationRecomUserService.getStationRecomUserByRangeId(helpPo.getRangeId());
//            if (stationRecomUser != null && stationRecomUser.getSumHeatValue() >= maxHotValue) {
//                helpVo.setSuccessFlag(false);
//                helpVo.setFullFlag(true);
//                return helpVo;
//            }
//        }
//
//        // 保存助力表
//        if (CollectionUtils.isNotEmpty(list)) {
//            for (StationRecomUserParking param : list) {
//                StationRecomShare stationRecomShare = new StationRecomShare();
//                stationRecomShare.setCreateTime(new Date());
//                stationRecomShare.setHeatValue(Double.parseDouble(Integer.toString(helpHotValue)));
//                stationRecomShare.setOpenId(helpPo.getOpenId());
//                stationRecomShare.setOpenName(helpPo.getXwName());
//                stationRecomShare.setOpenUrl(helpPo.getXwUrl());
//                stationRecomShare.setPoisId(param.getPoisId());
//                stationRecomShare.setRangeId(helpPo.getRangeId());
//                stationRecomShare.setUserId(param.getUserId());
//
//                int result = stationRecomShareMapper.insertSelective(stationRecomShare);
//                logger.info("rangeId={},,openId={} stationRecomShare save result={}", helpPo.getRangeId(), helpPo.getOpenId(), result);
//                if (result <= 0) {
//                    logger.error("rangeId={},,openId={} stationRecomShare save fail", helpPo.getRangeId(), helpPo.getOpenId());
//                    helpVo.setSuccessFlag(false);
//                    return helpVo;
//                }
//            }
//        }
//
//        // 计算热力值
//        int hotValue = this.calculateHotValue(helpPo.getRangeId(), applyHotValue, helpHotValue, maxHotValue);
//
//        // 更新station_recom_user表的热力值
//        int result = stationRecomUserMapper.updateHotValueByRangeId(helpPo.getRangeId(), hotValue);
//        if (result <= 0) {
//            logger.error("rangeId={},,update hotValue result={}", helpPo.getRangeId(), result);
//            helpVo.setSuccessFlag(false);
//            return helpVo;
//        }
//
//        helpVo.setSuccessFlag(true);
//        helpVo.setHotPowerValue(hotValue);
//        return helpVo;
//    }
//
//    @Override
//    public HelpNumOfSuccessParkingVo recommendNumOfSuccessParking(String parkingId) {
//        Long startTime = System.currentTimeMillis();
//        Integer count = stationRecomShareMapper.countRecommendNumOfSuccessParking(parkingId);
//        HelpNumOfSuccessParkingVo helpNumOfSuccessParkingVo = new HelpNumOfSuccessParkingVo();
//        helpNumOfSuccessParkingVo.setHelpNum(count);
//        Long entTime = System.currentTimeMillis();
//        logger.info("recommendNumOfSuccessParking parkingId={},,startTime={},,entTime={},,useTime={}", parkingId, startTime, entTime, entTime - startTime);
//        return helpNumOfSuccessParkingVo;
//    }
//
//    /**
//     * 根据状态返回不同MODEL
//     * @param status
//     * @param recommendDetailVo
//     */
//    private void returnModelByStatus(boolean status, RecommendDetailVo recommendDetailVo, String rangeId) {
//        if (status) {
//            // 获取圈内推荐成功的网点
//            SuccessModel successModel = stationRecomUserParkingMapper.getBuildSuccessParking(rangeId);
//
//            // 可用车辆数，由API调用车辆服务处理，我方不做处理
//            int carNum = 0;
//            String parkingId = null;
//            if (successModel != null) {
//                StationInfoPo stationInfoPo = new StationInfoPo();
//                stationInfoPo.setPoisId(successModel.getPoiId());
//                StationInfo stationInfo = stationInfoService.getStationByExample(stationInfoPo);
//                if (stationInfo != null) {
//                    parkingId = stationInfo.getParkingId();
//                }
//            }else {
//                successModel = new SuccessModel();
//            }
//            successModel.setCarNum(carNum);
//            successModel.setParkingId(parkingId);
//
//            recommendDetailVo.setSuccessModel(successModel);
//        }
//    }
//
//    /**
//     * 获取好友列表
//     * @param rangeId
//     * @param recommendDetailVo
//     */
//    private void getFirendList(String rangeId, RecommendDetailVo recommendDetailVo) {
//        List<Firend> firends = Lists.newArrayList();
//
//        StationRecomShareCriteria stationRecomShareCriteria = new StationRecomShareCriteria();
//        StationRecomShareCriteria.Criteria criteria = stationRecomShareCriteria.createCriteria();
//        criteria.andRangeIdEqualTo(rangeId);
//        List<StationRecomShare> stationRecomShare = stationRecomShareMapper.selectByExample(stationRecomShareCriteria);
//        if (CollectionUtils.isNotEmpty(stationRecomShare)) {
//            for (StationRecomShare param : stationRecomShare) {
//                Firend firend = new Firend();
//                firend.setXwName(param.getOpenName());
//                firend.setXwIcon(param.getOpenUrl());
//                firend.setCreateTime(param.getCreateTime());
//                firend.setOpenId(param.getOpenId());
//
//                firends.add(firend);
//            }
//        }
//        // 去重好友列表
//        firends = this.removeDuplicate(firends);
//
//        // 最多返回20个头像
//        if (firends.size() > FIREND_LIST_MAX_SIZE) {
//            firends = firends.stream().limit(FIREND_LIST_MAX_SIZE).collect(Collectors.toList());
//        }
//        // 对头像按时间倒序排序
//        if (CollectionUtils.isNotEmpty(firends)) {
//            firends = firends.stream().sorted(Comparator.comparing(Firend::getCreateTime).reversed()).collect(Collectors.toList());
//        }
//        recommendDetailVo.setFirendList(firends);
//        recommendDetailVo.setFirendSize(firends.size());
//    }
//
//    /**
//     * 保存申请范围信息
//     * @param recommendBuildParkingPo
//     * @return
//     */
//    private int saveCircleInfo(RecommendBuildParkingPo recommendBuildParkingPo) {
//        // 推荐成功热力值配置在字典表里
//        StationCarDictionaryConfig stationCarDictionaryConfig = stationCarDictionaryConfigService.getStationCarDictionaryConfigById(DictionaryConfigEnum.id_eighteen.getCode());
//        // 默认值100
//        String value = null!=stationCarDictionaryConfig && StringUtils.isNotBlank(stationCarDictionaryConfig.getConfigValue())?stationCarDictionaryConfig.getConfigValue():"100";
//
//        StationRecomUser stationRecomUser = new StationRecomUser();
//        stationRecomUser.setUserId(recommendBuildParkingPo.getUserId());
//        stationRecomUser.setRangeId(recommendBuildParkingPo.getRangeId());
//        stationRecomUser.setRangeName(recommendBuildParkingPo.getCenterPoint().getCenterPointName());
//        stationRecomUser.setRangeAddress(recommendBuildParkingPo.getCenterPoint().getCenterPointAddress());
//        // 推荐默认热力值100
//        stationRecomUser.setSumHeatValue(Double.parseDouble(value));
//        stationRecomUser.setLon(recommendBuildParkingPo.getCenterPoint().getLon());
//        stationRecomUser.setLat(recommendBuildParkingPo.getCenterPoint().getLat());
//        stationRecomUser.setTag(recommendBuildParkingPo.getTag());
//        stationRecomUser.setCreateTime(new Date());
//        stationRecomUser.setUpdateTime(new Date());
//        String cityCode = null;
//        String cityName = null;
//        List<RecommendParking> list = recommendBuildParkingPo.getParkingList();
//        // 获取cityCode,cityName。前端传过来的cityCode有部分为空的情况，循环获取
//        if (CollectionUtils.isNotEmpty(list)) {
//            for (RecommendParking recommendParking : list) {
//                if (StringUtils.isNotBlank(recommendParking.getCityCode())) {
//                    cityCode = recommendParking.getCityCode();
//                    break;
//                }
//            }
//            for (RecommendParking recommendParking : list) {
//                if (StringUtils.isNotBlank(recommendParking.getCityName())) {
//                    cityName = recommendParking.getCityName();
//                    break;
//                }
//            }
//        }
//        stationRecomUser.setCityCode(cityCode);
//        stationRecomUser.setCityName(cityName);
//        return stationRecomUserMapper.insertSelective(stationRecomUser);
//    }
//
//    /**
//     * 保存圈内站点信息
//     * @param recommendParking
//     * @param recommendBuildParkingPo
//     * @return
//     */
//    private int savePoisInfo(RecommendParking recommendParking, RecommendBuildParkingPo recommendBuildParkingPo) {
//        StationRecomUserParking stationRecomUserParking = new StationRecomUserParking();
//        stationRecomUserParking.setUserId(recommendBuildParkingPo.getUserId());
//        stationRecomUserParking.setRangeId(recommendBuildParkingPo.getRangeId());
//        stationRecomUserParking.setPoisId(recommendParking.getPoiId());
//        stationRecomUserParking.setCreateTime(new Date());
//        return stationRecomUserParkingMapper.insertSelective(stationRecomUserParking);
//    }
//
//    @Override
//    public List<StationRecomUserParking> getStationRecomUserParking(String rangeId) {
//        StationRecomUserParkingCriteria stationRecomUserParkingCriteria = new StationRecomUserParkingCriteria();
//        StationRecomUserParkingCriteria.Criteria criteria = stationRecomUserParkingCriteria.createCriteria();
//        if (StringUtils.isNotBlank(rangeId)) {
//            criteria.andRangeIdEqualTo(rangeId);
//        }
//        return stationRecomUserParkingMapper.selectByExample(stationRecomUserParkingCriteria);
//    }
//
//    @Override
//    public Integer calculateHotValue(String rangeId, int applyHotValue, int helpHotValue, int maxHotValue) {
//        // 该圈有多少人助力过
//        StationRecomSharePo param = new StationRecomSharePo();
//        param.setRangeId(rangeId);
//        int count = stationRecomShareMapper.getStationRecomShareListPageCount(param);
//        // 计算助力圈的热力值 推荐热力值 + 助力热力值*助力人数
//        int hotValue = applyHotValue + helpHotValue * count;
//        // 判断是否超过最大值
//        int result = hotValue > maxHotValue ? maxHotValue : hotValue;
//        logger.info("rangeId={},,total hotValue={}", rangeId, result);
//        return result;
//    }
//
//    /**
//     * list去重
//     * @param list
//     * @return
//     */
//    private static List removeDuplicate(List list) {
//        HashSet h = new HashSet(list);
//        list.clear();
//        list.addAll(h);
//        return list;
//    }
//}
